# Copyright (C) 2018 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("//tools/build:rules.bzl", "api_library", "apic_template")

filegroup(
    name = "api_files",
    srcs = glob([
        "*.api",
    ]),
    visibility = ["//visibility:public"],
)

api_library(
    name = "api",
    api = "gvr.api",
    apiname = "gvr",
    includes = [":api_files"],
    visibility = ["//visibility:public"],
    deps = ["//gapis/messages:api"],
)

proto_library(
    name = "gvr_proto",
    srcs = ["resolvables.proto"],
    visibility = ["//visibility:public"],
    deps = ["//gapis/service/path:path_proto"],
)

go_proto_library(
    name = "gvr_go_proto",
    importpath = "github.com/google/gapid/gapis/api/gvr",
    proto = ":gvr_proto",
    visibility = ["//visibility:public"],
    deps = ["//gapis/service/path:go_default_library"],
)

apic_template(
    name = "generated",
    api = ":api",
    templates = [
        "//gapis/api/templates:api",
        "//gapis/api/templates:api_types",
        "//gapis/api/templates:mutate",
        "//gapis/api/templates:constant_sets",
        "//gapis/api/templates:convert",
        "//gapis/api/templates:proto",
    ],
    visibility = ["//visibility:public"],
)

go_library(
    name = "go_default_library",
    srcs = [
        "doc.go",
        "extension.go",
        "framebindings.go",
        "gvr.go",
        "importance.go",
    ],
    embed = [
        ":generated",  # keep
        ":gvr_go_proto",
    ],
    importpath = "github.com/google/gapid/gapis/api/gvr",
    visibility = ["//visibility:public"],
    deps = [
        "//core/data/dictionary:go_default_library",  # keep
        "//core/data/protoconv:go_default_library",  # keep
        "//core/event/task:go_default_library",  # keep
        "//core/image:go_default_library",
        "//core/math/interval:go_default_library",
        "//core/memory/arena:go_default_library",  # keep
        "//gapil/constset:go_default_library",  # keep
        "//gapis/api:go_default_library",
        "//gapis/api/gles:go_default_library",
        "//gapis/api/gvr/gvr_pb:go_default_library",  # keep
        "//gapis/api/sync:go_default_library",
        "//gapis/api/transform:go_default_library",
        "//gapis/capture:go_default_library",
        "//gapis/database:go_default_library",
        "//gapis/extensions:go_default_library",
        "//gapis/memory/memory_pb:go_default_library",  #keep
        "//gapis/messages:go_default_library",  # keep
        "//gapis/replay:go_default_library",
        "//gapis/resolve:go_default_library",
        "//gapis/resolve/cmdgrouper:go_default_library",
        "//gapis/service:go_default_library",
        "//gapis/service/memory_box:go_default_library",  #keep
        "//gapis/service/path:go_default_library",
        "//gapis/service/types:go_default_library",  #keep
        "//gapis/stringtable:go_default_library",  # keep
    ],
)
